home *** CD-ROM | disk | FTP | other *** search
-
- #include <WindowMgr.h>
- #include <ListMgr.h>
- #include <OSUtil.h>
- #include <EventMgr.h>
-
- #include "MacCalc.h"
- #include "CalcData.h"
- #include "Parser.h"
-
- void DoCalc( sheet_record_hdl )
- SHEET_WIN_HDL sheet_record_hdl ;
- {
- int i, j ;
- Str255 buffer ;
- Cell curr_cell ;
- int error ;
- char *err_mess ;
-
- /* Lock and dereference the handle */
- HLock( (Handle)sheet_record_hdl ) ;
- curr_sheet_ptr = *sheet_record_hdl ;
-
- /* Process all cells */
- for( i=0;i<MAX_ROWS;i++ ) {
- for( j=0;j<MAX_COLUMNS;j++) {
- switch( curr_sheet_ptr->sheet_data[i][j].type ) {
- /* If cell type is undefined then do nothing */
- case UNDEFINED:
- break ;
- /* If cell type is undefined then clear cell */
- case CLEARED:
- SetPt( &curr_cell, j+1, i+1 ) ;
- LClrCell( curr_cell, curr_sheet_ptr->sheet_list_hdl ) ;
- curr_sheet_ptr->sheet_data[i][j].type = UNDEFINED ;
- break ;
- /* If cell type is string then put string in cell */
- case STRING:
- SetPt( &curr_cell, j+1, i+1 ) ;
- LSetCell( &curr_sheet_ptr->sheet_data[i][j].formula[1],
- curr_sheet_ptr->sheet_data[i][j].formula[0],
- curr_cell,
- curr_sheet_ptr->sheet_list_hdl ) ;
- break ;
- case CONSTANT:
- SetPt( &curr_cell, j+1, i+1 ) ;
- curr_sheet_ptr->sheet_data[i][j].value =
- GetFloat( curr_sheet_ptr->sheet_data[i][j].formula, &error ) ;
- if( error ) {
- Alert( error, NULL ) ;
- err_mess = "\p***ERROR***" ;
- LSetCell( err_mess+1, *err_mess, curr_cell,
- curr_sheet_ptr->sheet_list_hdl ) ;
- }else{
- ftoa( curr_sheet_ptr->sheet_data[i][j].value, buffer ) ;
- LSetCell( &buffer[1],
- buffer[0],
- curr_cell,
- curr_sheet_ptr->sheet_list_hdl ) ;
- }
- break ;
- /* Parse formula then convert value to string and put in cell */
- case FORMULA:
- SetPt( &curr_cell, j+1, i+1 ) ;
- curr_sheet_ptr->sheet_data[i][j].value =
- ParseFormula( curr_sheet_ptr->sheet_data[i][j].formula, &error ) ;
- if( error ) {
- Alert( error, NULL ) ;
- err_mess = "\p***ERROR***" ;
- LSetCell( err_mess+1, *err_mess, curr_cell,
- curr_sheet_ptr->sheet_list_hdl ) ;
- }else{
- ftoa( curr_sheet_ptr->sheet_data[i][j].value, buffer ) ;
- LSetCell( &buffer[1],
- buffer[0],
- curr_cell,
- curr_sheet_ptr->sheet_list_hdl ) ;
- }
- break ;
- }
- }
- }
- calc_data = FALSE ;
- DrawGrid( curr_sheet_ptr->sheet_window_ptr ) ;
- HUnlock( (Handle)sheet_record_hdl ) ;
- return ;
- }